home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / apendixb.lha / appendixb / swap.h < prev   
Text File  |  1993-08-08  |  726b  |  45 lines

  1. / define a swap function for the various basic types
  2. ifndef SWAPH
  3.  define SWAPH
  4.  
  5. verload swap;
  6.  
  7. define defswap(typex)             \
  8.    inline void swap(typex &a, typex &b) \
  9.    {                     \
  10. typex tmp = a;             \
  11. a = b;                 \
  12. b = tmp;             \
  13.    }
  14.  
  15. / all basic types
  16. efswap(char)
  17. efswap(short)
  18. efswap(int)
  19. efswap(long)
  20.  
  21. ifndef NO_UNSIGNED_OVERLOADING
  22. efswap(unsigned char)
  23. efswap(unsigned short)
  24. efswap(unsigned int)
  25. efswap(unsigned long)
  26. endif /* NO_UNSIGNED_OVERLOADING */
  27.  
  28. efswap(float)
  29. efswap(double)
  30.  
  31. / pointers to each basic type
  32. efswap(char *)
  33. efswap(short *)
  34. efswap(int *)
  35. efswap(long *)
  36.  
  37. efswap(unsigned char *)
  38. efswap(unsigned short *)
  39. efswap(unsigned int *)
  40. efswap(unsigned long *)
  41.  
  42. efswap(float *)
  43. efswap(double *)
  44. endif /* SWAPH */
  45.